<template>
  <div class="Login_bigbox">
    <div class="EnterpriseRegister_tishi_bigbox" v-if="ts">
      <div class="EnterpriseRegister_tishi_box">
        <div class="EnterpriseRegister_tishi_nextbox">
          <div class="EnterpriseRegister_tishi_nextbox_top">
            <div class="EnterpriseRegister_tishi_nextbox_title">
              您的企业信息已提交成功
            </div>
            <div class="EnterpriseRegister_tishi_nextbox_text">
              稍后我们的工作人员将与您取得联系
            </div>
          </div>
          <a
            href="https://rc.yping.net/bxcompany/login.php"
            class="EnterpriseRegister_tishi_nextbox_but"
            >我知道了</a
          >
        </div>
        <div class="EnterpriseRegister_tishi_nextimg">
          <img src="../assets/on.png" class="EnterpriseRegister_tishi_img" />
        </div>
      </div>
    </div>
    <div class="EnterpriseRegister_tishi_bigbox" v-if="ts2">
      <div class="EnterpriseRegister_tishi_box">
        <div class="EnterpriseRegister_tishi_nextbox">
          <div class="EnterpriseRegister_tishi_nextbox_top">
            <div class="EnterpriseRegister_tishi_nextbox_title">
              企业入驻申请已通过
            </div>
            <div class="EnterpriseRegister_tishi_nextbox_text">
              现在去管理企业招聘信息
            </div>
          </div>
          <a
            class="EnterpriseRegister_tishi_nextbox_but"
            href="https://rc.yping.net/bxcompany/login.php"
            >企业登录</a
          >
        </div>
        <div class="EnterpriseRegister_tishi_nextimg">
          <img src="../assets/on.png" class="EnterpriseRegister_tishi_img" />
        </div>
      </div>
    </div>
    <div class="EnterpriseRegister_tishi_bigbox" v-if="ts3">
      <div class="EnterpriseRegister_tishi_box">
        <div class="EnterpriseRegister_tishi_nextbox">
          <div class="EnterpriseRegister_tishi_nextbox_top">
            <div class="EnterpriseRegister_tishi_nextbox_title">
              企业入驻申请被驳回
            </div>
            <div class="EnterpriseRegister_tishi_nextbox_text red">
              驳回原因：{{ flagstr }}
            </div>
          </div>
          <div class="EnterpriseRegister_tishi_nextbox_but" @click="getbut">
            去修改
          </div>
        </div>
        <div class="EnterpriseRegister_tishi_nextimg">
          <img src="../assets/on.png" class="EnterpriseRegister_tishi_img" />
        </div>
      </div>
    </div>
    <div class="Login_box">
      <div class="Login_box_top">
        <div class="Login_box_top_imgbox">
          <img src="../assets/logo.png" class="Login_box_top_img" />
        </div>
        <div class="Login_box_top_text">贡聘招聘系统企业管理端</div>
      </div>
      <div class="Login_box_main">
        <div class="Login_box_main_left">
          <img src="../assets/LoginLeft.png" class="Login_box_main_left_img" />
        </div>
        <div class="Login_box_main_right">
          <div class="Login_box_main_right_top">
            【企业管理员】请使用微信扫码登录
          </div>
          <div class="Login_box_main_right_bom">
            <div class="Login_box_main_right_bom_top">
              已有账号？
              <a
                href="https://rc.yping.net/bxcompany/login.php"
                class="Login_box_main_right_bom_top_click"
                >现在去登录</a
              >
            </div>
            <div class="Login_box_main_right_bom_main">
              <img :src="codeimg" class="Login_box_main_right_bom_main_img" />
            </div>
            <div class="Login_box_main_right_bom_bom">微信扫码授权登录</div>
          </div>
        </div>
      </div>
      <div class="Login_box_bom">
        Copyright C 2015-2023 All Rights Reserved 版权所有 贡聘 蜀ICP备1222
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref, getCurrentInstance } from "vue";
import BaseUrl from "../../test";
const { proxy } = getCurrentInstance();
//**************************************数据定义**************************************
//SessionID
const SessionID = ref();
//二维码图片定义
const codeimg = ref();
//是否登录
const LoginCode = ref(true);
//appopenid
const appopenid = ref();
//审核备注
const flagstr = ref();
//提示
const ts = ref(false);
const ts2 = ref(false);
const ts3 = ref(false);
//**************************************数据请求**************************************
//获取 SessionID
const touch = () => {
  proxy
    .$Axios({
      method: "post",
      url: BaseUrl + "/wx.php/touch/",
    })
    .then((res) => {
      if (res.data.code == 0) {
        SessionID.value = res.data.data;
        codeFun();
      }
    });
};
//二维码图片请求
const codeFun = () => {
  proxy
    .$Axios({
      method: "post",
      url: BaseUrl + "/wx.php/getCompanyPageWXCODE/",
      data: {
        session: SessionID.value,
      },
    })
    .then((res) => {
      if (res.data.code == 0) {
        codeimg.value = res.data.data;
      }
    });
};
//是否登录轮询
const session = () => {
  proxy
    .$Axios({
      method: "post",
      url: BaseUrl + "/wx.php/getCompanyCodeWXID/",
      data: {
        session: SessionID.value,
      },
    })
    .then((res) => {
      sessionStorage.setItem("code", res.data.code);
      sessionStorage.setItem("data", res.data.data);
      appopenid.value = res.data.data;
      sessionStorage.setItem("message", res.data.message);
      if (res.data.data != null) {
        LoginCode.value = false;
      }
    });
};
//轮询方法
const login = setInterval(() => {
  session();
  if (LoginCode.value != true) {
    getcompanyinfobymember();
    clearInterval(login);
  }
}, 2000);
//获取数据
const getcompanyinfobymember = () => {
  proxy
    .$Axios({
      method: "post",
      url: BaseUrl + "/wx.php/getcompanyinfobymember/",
      data: {
        appopenid: appopenid.value,
      },
    })
    .then((res) => {
      if (res.data.code == 0) {
        if (res.data.data.flag == 0) {
          ts.value = true;
        } else if (res.data.data.flag == 1) {
          ts2.value = true;
        } else if (res.data.data.flag == 2) {
          ts3.value = true;
          flagstr.value = res.data.data.flagstr;
        }
      } else if (res.data.code == -1) {
        setTimeout(() => {
          proxy.$router.push("/EnterpriseRegister");
        }, 15);
      }
    });
};
//跳转
const getbut = () => {
  proxy.$router.push("/EnterpriseRegister");
};
//**************************************运行**************************************
touch();
</script>

<style>
@import url("./login.css");
</style>
